package com.gx.smart.base;

import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.LayoutRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.blankj.utilcode.util.BarUtils;

/**
 * 基础activity
 */
public abstract class BaseActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initStatusBar();
        setContentView(onBindLayout());
        initView();
        initContent();
        initData();
    }

    /**
     * 绑定布局
     *
     * @return
     */
    @LayoutRes
    protected abstract int onBindLayout();

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }


    protected void initStatusBar() {
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT);
        BarUtils.setStatusBarLightMode(this, true);
    }


    protected void initView() {

    }

    protected void initContent() {

    }

    protected void initData() {

    }


    /**
     * 初始化title
     *
     * @param title 标题
     */
    protected void initTitle(Toolbar title) {
        setSupportActionBar(title);
        ActionBar ab = getSupportActionBar();
        if (ab != null) {
            ab.setDisplayShowHomeEnabled(true);
            ab.setHomeAsUpIndicator(R.mipmap.arrow_left_white);
            ab.setDisplayHomeAsUpEnabled(true);
            ab.setTitle("");

        }
    }
}